home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Mousetools / MouseOff / MouseOff.orig < prev    next >
Text File  |  1996-09-26  |  2KB  |  85 lines

  1. /************************************************************************
  2.  
  3.    'MouseOff' will cause the mouse pointer to disappear and reappear if
  4.    movement is detected.  It will disappear again after 10 seconds of
  5.    inactivity.
  6.  
  7.    Usage:      Run MouseOff
  8.  
  9.    'MouseOFF' is public domain.  Please feel free to pass it anywhere
  10.    you want.
  11.  
  12.    Comments should be sent to:      Denny Jenkins
  13.                                     5226 Greensedge Way
  14.                                     Columbus, Ohio  43220
  15.  
  16.                                     CompuServe ID:  70003,2374
  17.  
  18. *************************************************************************/
  19.  
  20. #include <exec/types.h>
  21. #include <intuition/intuition.h>
  22.  
  23. struct   Screen           *s;
  24. struct   Window           *w, *OpenWindow();
  25. struct   IntuitionBase    *IntuitionBase;
  26. struct   Preferences      MyCopy;
  27. void                      *GfxBase;
  28.  
  29. struct NewWindow nw = {
  30.    0,0,3,10,
  31.    -1,-1,
  32.    NULL,
  33.    NULL,
  34.    NULL, NULL,
  35.    NULL,
  36.    NULL, NULL,
  37.    0,0,0,0,
  38.    WBENCHSCREEN
  39. };
  40.  
  41. ULONG  Seconds, Micros, Limit=0, Ten=10;
  42. SHORT  LastX, LastY;
  43. USHORT PointerData[POINTERSIZE];
  44. BOOL   Pointer=TRUE;
  45.  
  46. _main()
  47. {
  48.    register int i;
  49.  
  50.    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L);
  51.    GetPrefs (&MyCopy, (long) sizeof(MyCopy));
  52.    for (i=0; i<POINTERSIZE; i++)
  53.       PointerData[i] = MyCopy.PointerMatrix[i];
  54.    w = OpenWindow(&nw);
  55.    s = w->WScreen;
  56.    LastX = s->MouseX;
  57.    LastY = s->MouseY;
  58.  
  59.    FOREVER {
  60.       Delay(50);
  61.       CurrentTime(&Seconds,&Micros);
  62.       if(Seconds > Limit) {
  63.          if ((LastX == s->MouseX) && (LastY == s->MouseY)) {
  64.             if (Pointer) {
  65.                for (i=0; i<POINTERSIZE; i++)
  66.                   MyCopy.PointerMatrix[i] = NULL;
  67.                SetPrefs(&MyCopy, (long) sizeof(MyCopy));
  68.                Pointer = FALSE;
  69.             }
  70.          }
  71.          else {
  72.             LastX = s->MouseX;
  73.             LastY = s->MouseY;
  74.             if (!(Pointer)) {
  75.                for (i=0; i<POINTERSIZE; i++)
  76.                   MyCopy.PointerMatrix[i] = PointerData[i];
  77.                SetPrefs(&MyCopy, (long) sizeof(MyCopy));
  78.                Pointer = TRUE;
  79.                Limit = Seconds + Ten;
  80.             }
  81.          }
  82.       }
  83.    }
  84. }
  85.